package com.design_patterns.demo;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorDemo {

    private static ExecutorDemo executorDemo = new ExecutorDemo();

    ExecutorService executorService = Executors.newFixedThreadPool(1);

    private ExecutorDemo() {

    }

    public synchronized void doSql(Runnable thread) {
        executorService.execute(thread::run);
    }

    public void shutdown() {
        executorService.shutdown();
    }

    public static ExecutorDemo getInstance() {
        return executorDemo;
    }
}
